The Parallel Stacks window displays a call stack from the perspective
of parallel execution. Similar to the Threads and Call Stack windows,
the Parallel Tasks and Parallel Stacks windows are frequently used
together.
There are two views of the Parallel Stacks window: Threads view and
Tasks view. In the TPL, a task is the encapsulation of a parallel
operation. This is the reason developers focus on tasks when developing a
parallel application—threads are largely abstracted. However, when
things go wrong, information on threads is often helpful. For example,
knowing which threads share the same call stack can be useful. For this
reason, the Parallel Stacks window has both a Threads view and a Tasks
view. You can select the desired view in the drop-down list at the top
of the Parallel Stacks window.
The
Threads view of the Parallel Stacks window shows the call path of
threads through concurrent code. Each thread represents a separate path
of execution. Call stacks are represented as nodes or boxes in the
window. Each node lists methods of the call stack. The current stack
frame is highlighted with a yellow arrow, and a white arrow (if any)
indicates the stack frame in which execution was interrupted by the
debugger. The current path through the application is shown with a bold
blue arrow line. The status of a thread is shown above the call stack in
the terminating node. On the left side of the window, you can use the
Zoom slider control to scale the window.
There are a few method icons:
-
Yellow arrow
. The active stack frame for the current thread
-
Green arrow
. The active stack frame for a noncurrent thread
-
Cloths thread icon (two squiggly lines)
. The active stack frame for a noncurrent call stack
You can switch the current stack frame by double-clicking one of the
noncurrent frames. This changes the context for many things, such as the
local variables.
Some threads can follow the same path and share a common call stack.
When that occurs, that node is shared by multiple threads, as annotated
in the node header. In the diagram at the beginning of this section, two
threads share the {MG, MH, MI}
class stack. If you want to identify the specific threads, you can
point to the header. A tooltip appears that displays the thread
identifier and type for each thread, as shown in the next image.
The preceding diagram depicts two threads sharing a call stack. Afterward, the threads deviate. One thread calls the XClass.MJ method, while the other calls XClass.MK. You can point to the header for the nodes to identify the specific threads.
Obviously, pointing can be helpful in a variety of ways. For example,
when you point to a method in the call stack, the tooltip displays the
stack frame for each of the concurrent threads. In addition to the
thread identifier, the display includes parameters and source line
information. The stack frame for the current thread appears in bold
(when multiple threads are running through this particular call stack,
as shown here).
The Threads view has a toolbar that offers various commands.
From left to right, here’s an explanation of the toolbar buttons:
-
View drop-down list
. Toggles between the Threads view and the Tasks view
-
Stack frames
. Shows stack frames for threads flagged in the Threads window
-
Method view
. Shows the callers and callees of the current method
-
Auto Scroll To Current Stack Frame
. Scrolls to bring the current stack frame into the visible window
-
Toggle Zoom Control
. Toggles the Zoom slider control between visible and non-visible
You can right-click any method in the call stack to open a context menu, as shown in the following image.
The context menu commands are as follows:
-
Switch to Frame
. Selects the current method as the active stack frame
-
Go To Task
. In the Tasks view, shows the task for this method
-
Go To Source Code
. Jumps to the source code for a particular method
-
Go To Disassembly
. Opens the disassembly for a particular method
-
Show External Code
. Displays external code that is not in your code
-
Hexadecimal Display
. Switches between hexadecimal and decimal numbers
-
Symbol Load Information
. Displays the status of symbols for this method
-
Symbol Settings
. Allows you to configure symbol information
The Bird’s Eye View is a super cool feature. You can pan a reduced
version of the graph within a miniature window. This is useful if you
have a large diagram and want to quickly view a non-visible area. The
Bird’s Eye View button is at the intersection of the right and bottom
toolbars. When you click the button, an insert appears that contains the
diagram. The shaded area is your view. Click and drag within the Bird’s
Eye view to reposition the diagram. If the diagram is entirely visible,
neither the scrollbars nor the Bird’s Eye View button appear.
The
Tasks view shows the call stack of tasks and is the other view
available in the Parallel Stacks window. In general, this view presents
the application from the perspective of tasks and removes other
extraneous information. It shows the call path of tasks, where each node
is an individual call stack. The current path is highlighted with a
bold blue arrow. All this should sound familiar at this point, because
for ease of use, the Threads and Tasks views are similar.
Here is the Tasks view.
The preceding diagram shows five tasks. Two threads execute on the same call stack, which is {MI, MH, MG}. One of the tasks then calls MJ. The other task calls MK. Three threads share the {MC, MB, MA}
call stack before separating paths. If you point to a node header, you
will display a tooltip with information on each task in the call stack.
If you point to the header with three tasks, here’s what is displayed:
Within a node, you can point to a specific method. A tooltip appears
that provides the frame number, the full symbol name, the parameters,
and source line information, as shown next.
The
active stack frame of the current task is highlighted with a yellow
arrow. In general, the same arrows and other icons are available as in
the Threads view—but they apply to tasks rather than threads.
The end node of each call path includes the task status in the
header, shown as an icon. In the following end node, the red circle with
a dash indicates a deadlock. As in other examples, you can point to the
task header for more detail, as shown here.